package TimeTask任务调度;

import java.util.Timer;
import java.util.TimerTask;

public class Main {

	static int count = 0;

	public static void main(String[] args) {
		TimerTask timerTask = new TimerTask(){
			@Override
			public void run() {
				while (true) {
					try {
						Thread.sleep(1000);
						count++;
						System.out.println(count);
					} catch (Exception e) {
					}
				}
			}
		};

		Timer timer = new Timer();
		// 天数
		long delay = 0;
		// 毫秒秒数
		long period = 1000;
		timer.scheduleAtFixedRate(timerTask, delay, period);
	}

}

